#include "cMeshManager.h"

void cMeshManager::Initialize( ID3D10Device * _device )
{
	device = _device;
}

MeshDataPtr cMeshManager::LoadMesh( const std::wstring & fileName )
{
	auto iter = MeshesData.find(fileName);
	if(iter != MeshesData.end())
	{
		return iter->second;
	}
	else
	{
		MeshData * ptr = new MeshData;
		if(!MeshLoader.Load(fileName, device, ptr))
		{
			delete ptr;
			return nullptr;
		}
		else
		{
			MeshesData[fileName] = MeshDataPtr(ptr);
			return MeshDataPtr(ptr);
		}
	}
}

void cMeshManager::AddDirectly( MeshDataPtr meshPtr, std::wstring name )
{
	MeshesData[name] = meshPtr;
}
